<?php
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = '直播管理';
?>
<div class="container">
    <div class="row">

        <?php echo $this->render('_leftnav') ?>

        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">直播管理</h1>
            <div class="pull-right">


            </div>
          </div>

  <div class="btn-group">
  <a href="#" type="button" name="opening" class="btn btn-default btn-sm btn-primary">当前进行中</a>
  <a href="#" type="button" name="coming" class="btn btn-default btn-sm ">即将开始的</a>
  <a href="#" type="button" name="end" class="btn btn-default btn-sm ">已结束的</a>
 </div>  <br>

  <table class="table table-striped table-hover mtl" id="course-table">
    <thead>
    <tr>
      <th width="50%">课时</th>
      <th>直播时间</th>
      <th>最大参与人数</th>
      <th><a href="http://admin.bwphp.com/index.php?r=course/live"><span class="glyphicon glyphicon-refresh"></span></a></th>
    </tr>
    </thead>
    <tbody id="tbody">
      <?php foreach ($periods as $key => $period) { ?>
      <tr>
        <td>
          <a href="#" target="_blank"><?php echo $period['course']['course_name'] ?></a>
          <div class="mts">
            <a class="text-success text-sm" href="#" target="_blank"><?php echo $period['period_name'] ?></a>
          </div>
        </td>
          <td><?php echo date("Y-m-d H:i",$period['open_time'])."到".date("H:i",$period['end_time']) ?></td>
        <td>100 </td>
        <td></td>
      </tr>
      <?php } ?>
      <?php if (!$periods) { ?>
        <tr><td colspan="20"><div class="empty">暂无进行中的直播</div></td></tr>
      <?php } ?>
    </tbody>
  </table>
  </div>
  </div>
  </div>

  <script>
  $(function() {
    $(".btn-default").click(function() {
        var type = $(this).attr('name');
        $(".btn-default").removeClass('btn-primary');
        $(this).addClass('btn-primary');
        $.ajax({
          url: "<?php echo Url::to(['course/live']);?>",
          type: 'get',
          dataType: 'html',
          data: {type:type},
          success:function(msg){
              $("#tbody").html(msg);
          }
        })


    });

  })

  </script>

